﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class UserControl_NewestCompany : System.Web.UI.UserControl
{
    security baomat = new security();
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            using (Up1VNDataContext dc = new Up1VNDataContext())
            {
                var query = from o in dc.EStores
                            join u in dc.Users on o.Users_Id equals u.Users_Id
                            orderby o.EStore_CreatedDate
                            select new { 
                                o.EStore_Name, o.EStore_Id, o.EStore_Logo, o.Estore_HomePhone, o.EStore_MobilePhone,
                                u.Users_Email
                            };
                if (query.Count() > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var item in query)
                    {
                        sb.Append("<div class='content_panels'>");
                        string logo = (item.EStore_Logo != null) ? ResolveUrl("~/User/avatar/" + item.EStore_Logo) : ResolveUrl("~/images/logo_box.jpg");
                        sb.Append("<a href='" + baomat.RemoveSpecialCharacter(item.EStore_Name).Replace(" ", "-").ToLower() + "/Thongtindoanhnghiep.html'><img src='" + logo + "' alt='" + item.EStore_Name + "' title='" + item.EStore_Name + "' align='left' /></a>");
                        sb.Append("<h4><a href='" + baomat.RemoveSpecialCharacter(item.EStore_Name).Replace(" ", "-").ToLower() + "/Thongtindoanhnghiep.html'>" + item.EStore_Name + "</a><br /></h4>");
                        sb.Append("<h5>[P] " + item.Estore_HomePhone + "<br />[M] " + item.EStore_MobilePhone + "<br />[E] " + item.Users_Email + "</h5>");
                        sb.Append("<br class='clear' />");
                        sb.Append("</div>");
                    }
                    ltrNewest.Text = sb.ToString();
                }
            }
        }
        catch (Exception ex)
        {
        }
    }
}